package com.cby.springboot.demo.service;

import com.cby.springboot.demo.bean.AdminRoleMenu;
import com.cby.springboot.demo.mapper.AdminRoleMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("adminRoleMenuService")
public class AdminRoleMenuServiceImpl implements AdminRoleMenuService{

    @Autowired
    AdminRoleMenuMapper mapper;


    @Override
    public List<AdminRoleMenu> findAllByRid(int rid) {
        return mapper.findAllByRid(rid);
    }

    @Override
    public List<AdminRoleMenu> findAllByRid(List<Integer> rids) {
        int size = rids == null ? 0 : rids.size();
        List<AdminRoleMenu> result = new ArrayList<>();
        if(size > 0) {
            for (int i = 0; i < size; i++) {
                result.addAll(findAllByRid(rids.get(i)));
            }
        }
        return result;
    }

    @Override
    public void deleteAllByRid(int rid) {
        mapper.deleteAllByRid(rid);
    }
}
